//
//  ActivityTableViewCell.m
//  MyProject
//
//  Created by dllo on 15/11/2.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "ActivityTableViewCell.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation ActivityTableViewCell

- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
    
}


- (void)create{
    
    self.image = [[UIImageView alloc] init];
    [self addSubview:self.image];
    [self.image release];
    
    self.imagePhoto = [[UIImageView alloc] init];
    [self addSubview:self.imagePhoto];
    [self.imagePhoto release];
    
    self.labelDetail = [[UILabel alloc] init];
    [self addSubview:self.labelDetail];
    [self.labelDetail release];
    
    self.labelProduce = [[UILabel alloc] init];
    [self addSubview:self.labelProduce];
    [self.labelProduce release];
    
    self.labelActivity = [[UILabel alloc] init];
    [self addSubview:self.labelActivity];
    [self.labelActivity release];
    
    
}

- (void)layoutSubviews{
    
//    self.image.layer.borderWidth = 1;
//    self.imagePhoto.layer.borderWidth = 1;
//    self.imageView.layer.borderWidth = 1;
//    self.labelActivity.layer.borderWidth = 1;
//    self.labelDetail.layer.borderWidth = 1;
//    self.labelProduce.layer.borderWidth = 1;
    
    
    
    self.image.frame = CGRectMake(0, 0, WIDTH, HEIGHT / 3 * 2);
    self.labelProduce.frame =CGRectMake(0, HEIGHT / 3 * 2, WIDTH, HEIGHT / 3 / 3 * 2);
    self.labelProduce.numberOfLines = 0;
    self.labelProduce.font = [UIFont systemFontOfSize:15];
    
    self.imagePhoto.frame = CGRectMake(0, HEIGHT / 3 * 2 + HEIGHT / 3 / 3 * 2, WIDTH / 2 / 2 / 2, HEIGHT / 3 / 3 );
    self.labelDetail.frame = CGRectMake(WIDTH / 2 / 2 / 2, HEIGHT / 3 * 2 + HEIGHT / 3 / 3 * 2, WIDTH / 2 / 2, HEIGHT / 3 / 3);
    self.labelActivity.frame = CGRectMake(WIDTH / 2 , HEIGHT / 3 * 2 + HEIGHT / 3 / 3 * 2, WIDTH / 2 , HEIGHT / 3 / 3);
    
    self.labelDetail.font = [UIFont systemFontOfSize:15];
    self.labelActivity.font = [UIFont systemFontOfSize:15];
    self.labelDetail.textColor = [UIColor redColor];
    self.labelActivity.textColor = [UIColor redColor];
    self.labelActivity.textAlignment = 2;
    
    
}



- (void)setModelActivity:(ActivityModel *)modelActivity{
    
    if (_modelActivity != modelActivity) {
        [_modelActivity release];
        _modelActivity = [modelActivity retain];
    }
    [self.image sd_setImageWithURL:self.modelActivity.img[@"small"]];
    self.labelProduce.text = [NSString stringWithFormat: @"%@", self.modelActivity.smalltext];
    self.labelDetail.text = [NSString stringWithFormat:@"%@个作品", self.modelActivity.post_num];
    self.labelActivity.text = self.modelActivity.end_date;
    self.imagePhoto.image = [UIImage imageNamed:@"activity.png"];
    
    
    
    
}







@end
